<%@ page contentType="text/html; charset=utf-8"%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <!-- 引入 echarts.js -->
    <script src="${etx}/components/chart/echarts/echarts.min.js"></script>
    <script src="${etx}/components/zTree/js/jquery-1.4.4.min.js"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="width: 800px;height:500px;"></div>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    $.get("statChartAction_getonlineinfo","",function (json) {
    // 指定图表的配置项和数据
   var option = {
        title: {
            text: '一天24小时系统使用分布',
            subtext: '纯属虚构'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross'
            }
        },
        toolbox: {
            show: true,
            feature: {
                saveAsImage: {}
            }
        },
        xAxis:  {
            type: 'category',
            boundaryGap: false,
            data: json.factoryName,
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                formatter: '{value} 次'
            },
            axisPointer: {
                snap: true
            }
        },
        visualMap: {
            show: false,
            dimension: 0,
            pieces: [{
                lte: 6,
                color: 'green'
            }, {
                gt: 6,
                lte: 8,
                color: 'red'
            }, {
                gt: 8,
                lte: 14,
                color: 'green'
            }, {
                gt: 14,
                lte: 17,
                color: 'red'
            }, {
                gt: 17,
                color: 'green'
            }]
        },
        series: [
            {
                name:'使用量',
                type:'line',
                smooth: true,
                data:json.factoryProductNo,
                markArea: {
                    data: [ [{
                        name: '早高峰',
                        xAxis: '10'
                    }, {
                        xAxis: '12'
                    }], [{
                        name: '晚高峰',
                        xAxis: '15'
                    }, {
                        xAxis: '17'
                    }] ]
                }
            }
        ]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    },'json')
</script>
</body>
</html>